Repository navigation
fix(python): ship a PEP 561 py.typed marker and make the stubs mypy-clean - #243
Merged
Merged
Conversation
…lean The wheels carry .pyi stubs for the whole package but no py.typed marker, so mypy ignored them and every ioh import degraded to Any. Add the empty marker (both the wheel's packages list and the sdist include pick it up from ioh/), and fix the errors the now-honoured stubs themselves report: - None defaults on parameters typed as str/Callable/list in wrap_problem, Experiment and add_custom_problem - any/callable used as types in Experiment.apply/add_custom_problem - the logger stub importing the property submodule under the name property, which shadowed the builtin decorator for every class-level @Property in the file - __call__ overloads whose 1-D and 2-D variants were indistinguishable to mypy (shape is now expressed in the ndarray type parameter) - MetaData.__eq__ widened to the object supertype signature Fixes IOHprofiler#237
jacobdenobel
approved these changes
Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The wheels ship
.pyistubs for the whole package, but nopy.typedmarker (PEP 561), so mypy ignores them and everyiohimport degrades toAny(Skipping analyzing "ioh": module is installed, but missing library stubs or py.typed marker). Fixes #237.Root cause
An empty
ioh/py.typedis missing from the package. With the marker in place, mypy starts honouring the stubs — and then reports 22 errors in the stubs themselves, so the marker alone would trade one problem for another.Fix
ioh/py.typed;wheel.packages = ["ioh"]and the sdist's/ioh/include pick it up with no packaging changes.wrap_problem,Experiment.__init__andadd_custom_problem:Nonedefaults on parameters typedstr/Callable/list→ explicit| None;Experiment.apply/add_custom_problem:any/callableused as types →typing.Any/typing.Callable[..., typing.Any];iohcpp/logger/__init__.pyi: thepropertysubmodule was re-exported under the nameproperty, shadowing the builtin decorator for every class-level@propertyin the file (9 × "Module not callable"); it is now imported by full path under a local alias;iohcpp/problem/__init__.pyi: the 1-D and 2-D__call__overloads were indistinguishable to mypy (theAnnotatedshape metadata is invisible to it), so the 2-D signature was reported as unreachable; the shape is now expressed in thendarraytype parameter;MetaData.__eq__widened to theobjectsupertype signature, and the unhashable marker kept via an explicit ignore (mypy 2.x no longer accepts a bare__hash__ = None).Testing
mypy -p ioh: 22 errors →Success: no issues found in 12 source files..pyi+py.typed, no compiled module):reveal_type(ioh.get_problem)now reports the full signature from the issue's expected output instead ofAny.